package com.yyl.fmall.user.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yyl.fmall.user.entity.UserAddr;
import com.yyl.fmall.user.service.IUserAddrService;
import com.yyl.fmall.utils.CommonConstants;
import com.yyl.fmall.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户地址  前端控制器
 * </p>
 *
 * @author YuanSir
 * @since 2022-11-08
 */
@RestController
@RequestMapping("/useraddr")
@CrossOrigin
public class UserAddrController {
    
    @Autowired
    private IUserAddrService userAddrService;
    
    @GetMapping("/list")
    public R list(Integer userId){
    
        List<UserAddr> userAddrList = userAddrService.list(new LambdaQueryWrapper<UserAddr>()
                .eq(UserAddr::getUserId, userId));
        
        return R.ok().put(CommonConstants.R_MAP_KEY, userAddrList);
    
    }

}
